package com.vc.aha_server_event.service;

import com.vc.aha_server_event.dao.TravelThroughPageDAO;
import com.vc.aha_server_event.dto.TravelThroughPageDTO;
import com.vc.aha_server_event.dto.TravelThroughPageDataDTO;
import com.vc.aha_server_event.entity.Test;
import com.vc.aha_server_event.entity.TravelThroughPage;
import com.vc.aha_server_event.mapper.TestMapper;
import lombok.extern.slf4j.Slf4j;
import org.bson.types.ObjectId;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 埋点入库业务类
 *
 * @author Vc
 * @date 2022/03/30 15:01
 */
@Slf4j
@Service
public class TravelTroughPageService {
    @Resource
    private RedisService redisService;
    @Resource
    private TravelThroughPageDAO travelThroughPageDAO;
    @Resource
    private TestMapper testMapper;

    /**
     * 增加一条埋点数据
     */
    public ObjectId addTravelThroughPage(TravelThroughPage travelThroughPage) {
        TravelThroughPage save = travelThroughPageDAO.save(travelThroughPage);
        Date date = new Date();
        redisService.sAdd("test", date.toString() + " test addTravelThroughPage" );
        System.out.println(redisService.sGet("test"));
        testMapper.insert(Test.builder().date(new Date()).name("test").build());
        return save.getId();
    }
}
